<?php

$filename='base64.dat';
$fh = fopen ( $filename, "a+" );
if ( !$fh ) {
	die ( "fail to open $filename." );
}

flock ( $fh, LOCK_EX );

$records_count = 100000;
$time_start = time();
for ( $i=0; $i<$records_count; $i++ ) {
	$key_prefix = 'abcdefghijklmnopqrstuvwxyz';

	$key = sprintf ( "%s%d", $key_prefix, $i );
	$value = base64_encode( gzcompress( $key ) );
	fwrite ( $fh, "$key\t$value\n" );
}
$time_stop = time();
$time_last = $time_stop - $time_start;

$tps = $records_count / $time_last;

echo "recods_count={$records_count} time_last={$time_last} tps={$tps}\n";

flock ( $fh, LOCK_UN );

fclose ( $fh );

?>
